<script type="text/javascript">
$(document).ready(function() {ldelim}

	$('#poll_start').datetimepicker({ldelim}
		changeMonth: true,
        changeYear: true,
		timeOnlyTitle: 'Выберите время',
		timeText: 'Время',
		hourText: 'Часы',
		minuteText: 'Минуты',
		secondText: 'Секунды',
		currentText: 'Теперь',
		closeText: 'Закрыть',

		onClose: function(dateText, inst) {ldelim}
        var endDateTextBox = $('#poll_stop');
        if (endDateTextBox.val() != '') {ldelim}
            var testStartDate = new Date(dateText);
            var testEndDate = new Date(endDateTextBox.val());
            if (testStartDate > testEndDate)
                endDateTextBox.val(dateText);
        {rdelim}
        else {ldelim}
            endDateTextBox.val(dateText);
        {rdelim}
	    {rdelim},
	    onSelect: function (selectedDateTime){ldelim}
	        var start = $(this).datetimepicker('getDate');
	        $('#poll_stop').datetimepicker('option', 'minDate', new Date(start.getTime()));
	    {rdelim}
	{rdelim});


	$('#poll_stop').datetimepicker({ldelim}
		changeMonth: true,
        changeYear: true,
		timeOnlyTitle: 'Выберите время',
		timeText: 'Время',
		hourText: 'Часы',
		minuteText: 'Минуты',
		secondText: 'Секунды',
		currentText: 'Теперь',
		closeText: 'Закрыть',

		onClose: function(dateText, inst) {ldelim}
        var startDateTextBox = $('#poll_start');
        if (startDateTextBox.val() != '') {ldelim}
            var testStartDate = new Date(startDateTextBox.val());
            var testEndDate = new Date(dateText);
            if (testStartDate > testEndDate)
                startDateTextBox.val(dateText);
        {rdelim}
        else {ldelim}
            startDateTextBox.val(dateText);
        {rdelim}
    {rdelim},
    onSelect: function (selectedDateTime){ldelim}
        var end = $(this).datetimepicker('getDate');
        $('#poll_start').datetimepicker('option', 'maxDate', new Date(end.getTime()) );
    {rdelim}
	{rdelim});

{rdelim});
</script>





<div class="title"><h5>Управление модулем Опросы</h5></div>
<div class="widget" style="margin-top: 0px;">
    <div class="body">{#POLL_NEW_INFO#}</div>
</div>


<div class="breadCrumbHolder module">
	<div class="breadCrumb module">
	    <ul>
	        <li class="firstB"><a href="index.php" title="{#MAIN_PAGE#}">{#MAIN_PAGE#}</a></li>
	        <li><a href="index.php?do=modules&amp;cp={$sess}">{#MODULES_SUB_TITLE#}</a></li>
	        <li><a href="index.php?do=modules&action=modedit&mod=poll&moduleaction=1&cp={$sess}">Опросы</a></li> 
	    </ul>
	</div>
</div>



<div class="widget first">
	<ul class="tabs">
	    <li class="activeTab"><a href="#tab1">Существующие опросы</a></li>
	    <li class=""><a href="#tab2">Создать новый опрос</a></li>
	</ul>
	
	<div class="tab_container">

{*
<div class="infobox">
	<a href="javascript:void(0);" onclick="cp_pop('index.php?do=modules&action=modedit&mod=poll&moduleaction=new&cp={$sess}&pop=1','850','750','1','modpollnew');">{#POLL_NEW_LINK#}</a>
</div><br />
*}

<div id="tab1" class="tab_content" style="display: block;">
	<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
	 <thead>
		<tr>
			<td align="center" width="1%"></td>
			<td>{#POLL_NAME#}</td>
			<td>{#POLL_SYSTEM_TAG#}</td>
			<td>{#POLL_START_END#}</td>
			<td>{#POLL_HITS_CMMENT#}</td>
			<td colspan="2" align="center" width="2%">{#POLL_ACTIONS#}</td>
		</tr>
	 </thead>	
	<tbody>
		{foreach from=$items item=item}
			<tr id="item_{$item->id}" class="maintr1">
				<td width="10">
					{if $item->poll_status != '1'}						
						<div class="icon_sprite ico_lock"></div>
					{else}
						<div class="icon_sprite ico_lock_no"></div>
					{/if}
				</td>
	
				<td><a href="index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&cp={$sess}&id={$item->id}"><strong>{$item->poll_title}</strong></a></td>
	
				<td><div class="pr12"><input type="text" value="[mod_poll:{$item->id}]" size="15" readonly=""></div></td>
	
				<td class="time">c {$item->poll_start|date_format:$TIME_FORMAT|pretty_date} по {$item->poll_end|date_format:$TIME_FORMAT|pretty_date}</td>
	
				<td>{if $item->sum_hits == ''}0{else}{$item->sum_hits}{/if} / <a href="javascript:void(0);" onclick="cp_pop('index.php?do=modules&action=modedit&mod=poll&moduleaction=comments&cp={$sess}&id={$item->id}&pop=1','850','750','1','modpolledit');">{$item->comments}</a></td>
	
				<td width="1%" align="center">
				{*<a title="{#POLL_EDIT_POLL#}" href="javascript:void(0);" onclick="cp_pop('index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&cp={$sess}&id={$item->id}&pop=1','850','750','1','modpolledit');"><img src="{$tpl_dir}/images/icon_edit.gif" alt="" border="0" /></a>*}
				
				
				<a title="{#POLL_EDIT_POLL#}" class="icon_sprite ico_edit" href="index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&cp={$sess}&id={$item->id}"></a>
				
				
				</td>
	
				<td width="1%" align="center">
				{*<a title="{#POLL_DELETE#}" onclick="return confirm('{#POLL_DELETE_CONFIRM#}');" href="index.php?do=modules&action=modedit&mod=poll&moduleaction=delete&cp={$sess}&id={$item->id}"><img src="{$tpl_dir}/images/icon_del.gif" alt="" border="0" /></a>*}
				
				<a title="{#POLL_DELETE#}" onclick="return confirm('{#POLL_DELETE_CONFIRM#}');" class="icon_sprite ico_delete" href="index.php?do=modules&action=modedit&mod=poll&moduleaction=delete&cp={$sess}&id={$item->id}"></a>
				</td>
			</tr>
		{/foreach}
	</tbody>
	</table>
	
	{if $page_nav} <div class="infobox">{$page_nav}</div> {/if}
	
</div>







	<div id="tab2" class="tab_content" style="display: none;">


{*
<div class="head"><h5 class="iFrames">{#POLL_SETTINGS_TITLE#}</h5></div>
*}
<form method="post" action="{$formaction}" class="mainForm">
<div class="hash"></div>	
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
	<col width="200">
	<tr>
		<td class="first">{#POLL_NAME#}:</td>
		<td class="second">
			<div class="pr12"><input name="poll_name" type="text" id="poll_name" value="{$row->poll_title}" size="50" /></div>
		</td>
	</tr>
	<tr>
		<td class="first">{#POLL_STATUS#}?</td>
		<td class="second">

			<div class="pr12">
            <input id="poll_status1" type="radio" name="poll_status" value="1" {if $row->poll_status==1}checked{/if}/>
            <label>{#POLL_YES#}</label>           
            
            <input id="poll_status2" type="radio" name="poll_status" value="0" {if $row->poll_status!=1}checked{/if}/>
            <label>{#POLL_NO#}</label>
			
			</div>			
			
			
		</td>
	</tr>
	<tr>
		<td class="first">{#POLL_CAN_COMMENT#}</td>
		<td class="second">
			
			<div class="pr12">
            <input id="poll_can_comment1" type="radio" name="poll_can_comment" value="1" {if $row->poll_can_comment==1}checked{/if}/>
            <label>{#POLL_YES#}</label>           
            
            <input id="poll_can_comment2" type="radio" name="poll_can_comment" value="0" {if $row->poll_can_comment!=1}checked{/if}/>
            <label>{#POLL_NO#}</label>
			
			</div>
			
			
		</td>
	</tr>
	<tr>
		<td class="first">{#POLL_START_TIME#}</td>
		<td class="second">
			<input id="poll_start" name="poll_start" type="text" value="{$row->poll_start|date_format:"%d.%m.%Y %H:%M"}"  style="width: 150px;"/>	
		</td>
	</tr>
	<tr>
		<td class="first">{#POLL_END_TIME#}</td>
		<td class="second">
			<input id="poll_stop" name="poll_stop" type="text" value="{$row->poll_end|date_format:"%d.%m.%Y %H:%M"}"  style="width: 150px;"/>	
		</td>
	</tr>
	<tr>
		<td valign="top" class="first">{#POLL_USER_GROUPS#}<br /><small>{#POLL_GROUP_INFO#}</small></td>
		<td class="second">
			<select style="width:200px"  name="groups[]" size="5" multiple="multiple">
				{html_options options=$groups selected=$selected}
			</select>
		</td>
	</tr>
	{if $smarty.request.id == ''}
		<tr>
			<td class="second" colspan="2"><input type="submit" class="basicBtn topDir" value="{#POLL_BUTTON_SAVE#}" /></td>
		</tr>
	{/if}
</table>




	{if $smarty.request.id != ''}
		<table width="100%" border="0" cellpadding="8" cellspacing="1" class="tableborder">
			<tr class="tableheader">
				<td align="center" width="1%"><img src="{$tpl_dir}/images/icon_del.gif" alt="" /></td>
				<td>{#POLL_QUESTION_NAME#}</td>
				<td>{#POLL_QUESTION_COLOR#} </td>
				<td>{#POLL_QUESTION_POSI#}</td>
				<td>{#POLL_QUESTION_HITS#}</td>
			</tr>

			{foreach from=$items item=item}
				<tr>
					<td width="1%"><input title="{#POLL_MARK_DELETE#}" name="del[{$item->id}]" type="checkbox" id="del[{$item->id}]" value="1" /></td>
					<td width="30%"><input style="width:250px" name="item_title[{$item->id}]" type="text" id="item_title[{$item->id}]" value="{$item->poll_item_title}" /></td>
					<td width="20%">
						<input maxlength="7" onblur="document.getElementById('b[{$item->id}]').style.background = this.value;" style="width:100px" type="text" name="line_color[{$item->id}]" value="{$item->poll_item_color}" />
						<input disabled type="button" id="b[{$item->id}]" style="background:{$item->poll_item_color}" value="&nbsp;&nbsp;">
					</td>
					<td width="12%"><input name="position[{$item->id}]" type="text" id="position[{$item->id}]" size="5" maxlength="3" value="{$item->poll_item_position}" /></td>
					<td width="20%"><input style="width:80px" name="poll_item_hits[{$item->id}]" type="text" id="poll_item_hits[{$item->id}]" value="{$item->poll_item_hits}" /></td>
				</tr>
			{/foreach}

			<tr class="second">
				<td colspan="5"><input type="submit" class="button" value="{#POLL_BUTTON_SAVE#}" /></td>
			</tr>
		</table>
	{/if}
</form>

{if $smarty.request.id != ''}
	<h4>Добавить новый вопрос</h4>
	<form method="post" action="index.php?do=modules&action=modedit&mod=poll&moduleaction=save_new&cp={$sess}&id={$smarty.request.id|escape}" name="new">
	<div class="hash"></div>
		<table width="100%" border="0" cellpadding="8" cellspacing="1" class="tableborder">
			<tr class="tableheader">
				<td>{#POLL_QUESTION_NAME#}</td>
				<td>{#POLL_QUESTION_COLOR#} </td>
				<td>{#POLL_QUESTION_POSI#}</td>
				<td>{#POLL_QUESTION_HITS#}</td>
			</tr>

			<tr class="first">
				<td width="30%"><input style="width:250px" name="item_title" type="text" id="item_title" value="" /></td>
				<td width="20%">
					<input maxlength="7" onblur="document.getElementById('b').style.background = this.value;" style="width:100px" type="text" name="line_color" value="" />
					<input disabled type="button" id="b" style="background:" value="&nbsp;&nbsp;">
				</td>
				<td width="12%"><input name="position" type="text" id="position" size="5" maxlength="3" value="" /></td>
				<td width="20%"><input style="width:80px" name="poll_item_hits" type="text" id="poll_item_hits" value="" /></td>
			</tr>

			<tr class="second">
				<td colspan="4"><input type="submit" class="button" value="{#POLL_BUTTON_ADD#}" /></td>
			</tr>
		</table>
	</form>
{/if}



</div>
</div>
<div class="fix"></div>


</div>